<?php 

class ChanServ extends AthemePHP {
	
	/**
	 * @param $xmlURL
	 */
	function ChanServ($xmlURL)
	{
		$this->xmlURL = $xmlURL;
		$this->include = false;
	}
	
	
	/**
	 * 
	 * @param $nick
	 * @param $athemeid
	 * @return unknown_type
	 */
	function GetChannels($nick, $athemeid)
	{
		$this->addParam('NICKSERV');
		$this->addParam('LISTCHANS');
		
		$result = $this->doCMD($nick, $athemeid);
		
		if($result['methodResponse']['fault']['value']['struct']['member'][0]['value']['int'])
		{
			$retRes = $result['methodResponse']['fault']['value']['struct']['member'][0]['value']['int'];
		} else {
			$retRes = nl2br($result['methodResponse']['params']['param']['value']['string']);
		}
		
		return $retRes;
	}
	
	/**
	 * 
	 * @param $channel
	 * @param $password
	 * @param $nick
	 * @param $athemeid
	 * @return unknown_type
	 */
	function Register($channel, $password, $nick, $athemeid)
	{
		$this->addParam('CHANSERV');
		$this->addParam('REGISTER');
		$this->addParam($channel);
		$this->addParam($password);
		
		$result = $this->doCMD($nick, $athemeid);
		
		return $result;
	}
	
}
?>